<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // indexOf（） 获取一个数组元素第一次出现的位置     有输索引号   没有-1

        let arr = ['a', 'b', 'b', 'v', 'a'];
        function indexOf2(arr, con) {
            for (let i = 0; i < arr.length - 1; i++) {
                if (arr[i] == con) {
                    return i;
                }
            }
            return -1;
        }
        console.log(indexOf2(arr, 'v'));
        console.log(indexOf2(arr, 'ac'));


    </script>
</body>

</html>